/*
 * @Description: provider
 * @Autor: lcz
 * @Date: 2022-08-15 10:23:16
 * @LastEditors: lcz
 * @LastEditTime: 2022-08-15 10:24:58
 */
import * as React from 'react'

export type SizeType = 'small' | 'middle' | 'large' | undefined

const SizeContext = React.createContext<SizeType>(undefined)

export interface SizeContextProps {
  size?: SizeType
  children?: React.ReactNode
}

export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => (
  //Consumer 接收 说明外面还有一层Provider 会传入sizeType
  <SizeContext.Consumer>
    {originSize => <SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>}
  </SizeContext.Consumer>
)

export default SizeContext
